package com.qf.day07.user;

import java.util.Scanner;

public class Menu {
    public void show(){
        //创建一个局部变量
        UserService userService=new UserServiseImpl();
        while (true){
            System.out.println("请选择功能:1.注册\t2.登录\t3.退出");
            Scanner scanner = new Scanner(System.in);
            int i=scanner.nextInt();
            switch (i){
                case 1:
                    System.out.println("请输入用户名:");
                    String nameRegis = scanner.next();
                    System.out.println("请输入用户密码:");
                    String password = scanner.next();
                    boolean flag1= userService.register(nameRegis,password);
                    if(flag1){
                        System.out.println("注册成功");
                    }else {
                        System.out.println("注册失败");
                    }
                    break;
                case 2:
                    System.out.println("请输入用户名:");
                    String nameLogin = scanner.next();
                    System.out.println("请输入用户密码:");
                    String loginPass = scanner.next();
                    boolean flag2= userService.login(nameLogin,loginPass);
                    if(flag2){
                        System.out.println("登录成功");
                    }else {
                        System.out.println("登录失败");
                    }
                    break;
                case 3:
                    System.out.println("886");
                    return;
                default:
                    System.out.println("输入错误");
            }
        }
    }
}
